﻿/*
 * Created by SharpDevelop.
 * User: Andrew
 * Date: 01/05/2013
 * Time: 17:47
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Drawing;
using RRRSRoguelike.Helpers;
using RRRSRoguelike.Helpers.Visualizer;
using RRRSRoguelike.Managers;

namespace RRRSRoguelike.Screens
{
	/// <summary>
	/// Description of BaseMenuScreen.
	/// </summary>
	public class BaseMenuScreen:Screen
	{
		
		Menu menu;
		
		public BaseMenuScreen()
		{	
			//Setup one panel to fill screen
			PanelList.Add(new MenuPanel(new Point(4, 3),
				Visualizer.GetScreenWidth() - 9,
				Visualizer.GetScreenHeight() - 6));
			
			menu = ((MenuPanel)PanelList[0]).Menu;
			
		}

		#region Methods

		public override void Show()
		{
			Draw();
			//The menthods below will set active to false when a selection is made.
			
			
			
			while (active)
			{
				//handle menu input and draw
				if (menu.HandleInput())
					menu.DrawMenu();
			}
		}

		protected void Draw()
		{
			Clear();
			PanelList[0].Draw();
			menu.DrawMenu();
		}

		//Event method
		void SelectNewGame(object sender, EventArgs e)
		{
            SessionVars.SetSeed();
            ApplicationManager.Instance.ScreenStack.Push(new DungeonScreen());
			active = false;
		}
		//Event method
		void SelectSeed(object sender, EventArgs e)
		{
			ApplicationManager.Instance.ScreenStack.Push(new SeedScreen());
			active = false;
		}
		//Event method
		void SelectLanguage(object sender, EventArgs e)
		{
			new LanguageScreen().Show();
			Clear();
			PanelList[0].Draw();
		}
		//Event method
		static void SelectBackupCustomContent(object sender, EventArgs e)
		{
			
			Language.BackupContentFolder();	
			Language.PrepareContentFolder();
			//HACK: No check to confirm it is actually done.
			var textScreen = new TextScreen("Done!");
			textScreen.Show();
		}
		//Event method
		static void SelectExit(object sender, EventArgs e)
		{
			ApplicationManager.Instance.Exit();
		}

		#endregion
	}
}
